<template>
  <div class="about">
    <h1>登录页面</h1>
    <el-form
      :model="ruleForm"
      status-icon
      ref="ruleForm"
      label-width="100px"
      class="demo-ruleForm"
    >
      <el-form-item label="用户名" prop="pass">
        <el-input type="text" v-model="ruleForm.username"></el-input>
      </el-form-item>
      <el-form-item label="确认密码" prop="checkPass">
        <el-input type="password" v-model="ruleForm.password"></el-input>
      </el-form-item>
      <el-form-item>
        <el-button type="primary" @click="onSumbit">提交</el-button>
      </el-form-item>
    </el-form>
  </div>
</template>
<script>
export default {
  data() {
    return {
      ruleForm: {
        password: "",
        username: "",
      },
    };
  },
  methods: {
    onSumbit() {
      this.$axios
        .post("http://ceshi5.dishait.cn/admin/login", {
          username: this.ruleForm.username,
          password: this.ruleForm.password,
        })
        .then((res) => {
          console.log(res);
          localStorage.setItem("token", res.data.data.token);
          this.$message({
            message: "登录成功",
            type: "success",
          })
          this.$router.push({path:"/home"})
        });
    },
  },
};
</script>

<style lang="scss">
  .about{
    width: 600px;
    margin: 100px auto;
  }
</style>
